package com.gnrsoft.springboot_test.jobs;

import javax.annotation.Resource;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.gnrsoft.springboot_test.aop.ExecTime;
import com.gnrsoft.springboot_test.commons.http.HttpResult;
import com.gnrsoft.springboot_test.commons.http.HttpService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class TestTask {

	@Resource
	HttpService httpService;

	@ExecTime
	@Scheduled(cron = "30 */15 * * * ?")
	public void test() {

		String url = "www.baidu.com";

		try {
			HttpResult httpResult = httpService.doPost(url);

			if ("200".equals(httpResult.getCode().toString())) {
				log.info("testTask success");
			}
		} catch (Exception e) {
			log.error("testTask error", e);
		}

	}

}
